package filter;

import org.apache.log4j.Logger;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(filterName = "AllFilter", urlPatterns = {
        "/api/*"
})
public class AllFilter implements Filter {
    private final Logger logger = Logger.getLogger(AllFilter.class);

    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        req.setCharacterEncoding("utf8");
        resp.setContentType("application/json");
        resp.setCharacterEncoding("utf-8");
        logger.info("AllFilter加载成功");
        chain.doFilter(req, resp);
    }

    public void init(FilterConfig config) throws ServletException {

    }

}
